package org.creativor.rayson.transport.server;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.nio.channels.SelectionKey;
import java.nio.channels.SocketChannel;
import org.creativor.rayson.transport.api.Connection;
import org.creativor.rayson.transport.api.TimeLimitConnection;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * The class <code>ConnectionManagerTest</code> contains tests for the class
 * <code>{@link ConnectionManager}</code>.
 * <p>
 * Copyright Creativor Studio (c) 2011
 * 
 * @generatedBy CodePro at 11-5-7 上午3:09
 * @author Nick Zhang
 * @version $Revision: 1.0 $
 */
public class ConnectionManagerTest {
	/**
	 * Launch the test.
	 * 
	 * @param args
	 *            the command line arguments
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:09
	 */
	public static void main(String[] args) {
		new org.junit.runner.JUnitCore().run(ConnectionManagerTest.class);
	}

	/**
	 * Perform pre-test initialization.
	 * 
	 * @throws Exception
	 *             if the initialization fails for some reason
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:09
	 */
	@Before
	public void setUp() throws Exception {
		// TODO: add additional set up code here
	}

	/**
	 * Perform post-test clean-up.
	 * 
	 * @throws Exception
	 *             if the clean-up fails for some reason
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:09
	 */
	@After
	public void tearDown() throws Exception {
		// TODO: add additional tear down code here
	}

	/**
	 * Run the void accept(long,TimeLimitConnection) method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:09
	 */
	@Test
	public void testAccept_1() throws Exception {
		ConnectionManager fixture = new ConnectionManager();
		long pendingId = 1L;
		TimeLimitConnection connection = new RpcConnection(1L,
				SocketChannel.open(), new PacketManager(), (SelectionKey) null, null);

		fixture.accept(pendingId, connection);

		// TODO: add additional test code here
	}

	/**
	 * Run the void acceptPending(PendingConnection) method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:09
	 */
	@Test
	public void testAcceptPending_1() throws Exception {
		ConnectionManager fixture = new ConnectionManager();
		PendingConnection connection = new PendingConnection(
				new TransportServer(), SocketChannel.open(),
				(SelectionKey) null);

		fixture.acceptPending(connection);

		// TODO: add additional test code here
	}

	/**
	 * Run the void acceptPending(PendingConnection) method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:09
	 */
	@Test
	public void testAcceptPending_2() throws Exception {
		ConnectionManager fixture = new ConnectionManager();
		PendingConnection connection = new PendingConnection(
				new TransportServer(), SocketChannel.open(),
				(SelectionKey) null);

		fixture.acceptPending(connection);

		// TODO: add additional test code here
	}

	/**
	 * Run the ConnectionManager() constructor test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:09
	 */
	@Test
	public void testConnectionManager_1() throws Exception {

		ConnectionManager result = new ConnectionManager();

		// TODO: add additional test code here
		assertNotNull(result);
		assertEquals(0, result.size());
		assertEquals("Thread[Connection manager,1,main]", result.toString());
		assertEquals(false, result.isInterrupted());
		assertEquals("Connection manager", result.getName());
		assertEquals(0, result.countStackFrames());
		assertEquals(6170L, result.getId());
		assertEquals(1, result.getPriority());
		assertEquals(false, result.isAlive());
		assertEquals(true, result.isDaemon());
	}

	/**
	 * Run the void quit() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:09
	 */
	@Test
	public void testQuit_1() throws Exception {
		ConnectionManager fixture = new ConnectionManager();

		fixture.quit();

		// TODO: add additional test code here
	}

	/**
	 * Run the void remove(Connection) method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:09
	 */
	@Test
	public void testRemove_1() throws Exception {
		ConnectionManager fixture = new ConnectionManager();
		Connection connection = new PendingConnection(new TransportServer(),
				SocketChannel.open(), (SelectionKey) null);

		fixture.remove(connection);

		// TODO: add additional test code here
	}

	/**
	 * Run the void removePending(PendingConnection) method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:09
	 */
	@Test
	public void testRemovePending_1() throws Exception {
		ConnectionManager fixture = new ConnectionManager();
		PendingConnection connection = new PendingConnection(
				new TransportServer(), SocketChannel.open(),
				(SelectionKey) null);

		fixture.removePending(connection);

		// TODO: add additional test code here
	}

	/**
	 * Run the void run() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:09
	 */
	@Test
	public void testRun_1() throws Exception {
		ConnectionManager fixture = new ConnectionManager();

		fixture.run();

		// TODO: add additional test code here
	}

	/**
	 * Run the void run() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:09
	 */
	@Test
	public void testRun_2() throws Exception {
		ConnectionManager fixture = new ConnectionManager();

		fixture.run();

		// TODO: add additional test code here
	}

	/**
	 * Run the int size() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:09
	 */
	@Test
	public void testSize_1() throws Exception {
		ConnectionManager fixture = new ConnectionManager();

		int result = fixture.size();

		// TODO: add additional test code here
		assertEquals(0, result);
	}
}